#!/bin/bash

FILES=( "actors.list" "actresses.list" "directors.list" \
    "writers.list" "producers.list" )

for file in ${FILES[@]}; do
    file="$file.tmp"
    BEGIN=$[`grep -n -m 1 "^Name" $file | awk -F : '{print $1}'`+2]
    END=$[`tail --lines=+$BEGIN $file | grep -n -m 1 -F --regexp="-------" | awk -F : '{print $1}'`-1]
    tail --lines=+$BEGIN $file | head --lines=$END > "${file/.tmp/.tmp2}"
    mv "${file/.tmp/.tmp2}" "$file"
done
